home *** CD-ROM | disk | FTP | other *** search
/ 3D GFX / 3D GFX.iso / amiutils / i_l / irit5 / triv_lib / mrchcube.h < prev    next >
C/C++ Source or Header  |  1995-12-30  |  4KB  |  104 lines

  1. /******************************************************************************
  2. * MarchCube.c - An implementation of the marching cube algorithm.          *
  3. *                                          *
  4. *                                                                             *
  5. *                     7            K           6                              *
  6. *                      ***********************                                *
  7. *                    * +                   * *                                *
  8. *                L *   +                 *   *              Vertices 0 - 7    *
  9. *                *     +     I         * J   *              Edges    A - L    *
  10. *            4 *********************** 5     *                                *
  11. *              *       +             *       *                                *
  12. *              *       +             *       * G                              *
  13. *              *       + H           *       *                                *
  14. *              *       +             *       *                                *
  15. *              *       +             * F     *                                *
  16. *            E *       +       C     *       *                                *
  17. *              *       ++++++++++++++*+++++++* 2                              *
  18. *              *   D + 3             *     *                                  *
  19. *              *   +                 *   * B                                  *
  20. *              * +                   * *                                      *
  21. *              ***********************                                        *
  22. *             0           A           1                                       *
  23. *                                                                             *
  24. *******************************************************************************
  25. * Written by Gershon Elber, Dec. 92.                          *
  26. ******************************************************************************/
  27.  
  28. #ifndef MARCH_CUBE_H
  29. #define MARCH_CUBE_H
  30.  
  31. #include <irit_sm.h>
  32. #include <triv_loc.h>
  33.  
  34. #define MC_VRTX_0 0
  35. #define MC_VRTX_1 1
  36. #define MC_VRTX_2 2
  37. #define MC_VRTX_3 3
  38. #define MC_VRTX_4 4
  39. #define MC_VRTX_5 5
  40. #define MC_VRTX_6 6
  41. #define MC_VRTX_7 7
  42. #define MC_VRTX_NONE 999
  43.  
  44. #define MC_EDGE_A 0
  45. #define MC_EDGE_B 1
  46. #define MC_EDGE_C 2
  47. #define MC_EDGE_D 3
  48. #define MC_EDGE_E 4
  49. #define MC_EDGE_F 5
  50. #define MC_EDGE_G 6
  51. #define MC_EDGE_H 7
  52. #define MC_EDGE_I 8
  53. #define MC_EDGE_J 9
  54. #define MC_EDGE_K 10
  55. #define MC_EDGE_L 11
  56. #define MC_EDGE_NONE 999
  57.  
  58. #define MC_COMP_V_POS(X, Y, Z, Pos) { \
  59.             CCS -> _VrtxPos[Pos][0] = CCS -> Vrtx0Lctn[0] + X; \
  60.             CCS -> _VrtxPos[Pos][1] = CCS -> Vrtx0Lctn[1] + Y; \
  61.             CCS -> _VrtxPos[Pos][2] = CCS -> Vrtx0Lctn[2] + Z; }
  62.  
  63.  
  64. typedef struct MCCubeCornerScalarStruct {
  65.     CagdPType Vrtx0Lctn;              /* Lowest corner position. */
  66.     CagdPType CubeDim;                     /* Width, Depth, Height. */
  67.     RealType Corners[8];            /* Scalar values of corners. */
  68.     RealType GradientX[8];            /* Optional gradient at corners. */
  69.     RealType GradientY[8];
  70.     RealType GradientZ[8];
  71.     CagdBType HasGradient;               /* True if Gradient? are set. */
  72.  
  73.     /* Used internally. */
  74.     CagdBType _Intersect;
  75.     RealType _Vertices[8];
  76.     CagdPType _VrtxPos[8];
  77.     CagdPType _InterNrml[12];
  78.     CagdPType _InterPos[12];
  79.     int _InterHighV[12];
  80. } MCCubeCornerScalarStruct;
  81.  
  82. typedef struct MCVertexStruct {
  83.     struct MCVertexStruct *Pnext;                /* To next in chain. */
  84.     CagdPType V;                   /* Holds X, Y, Z coordinates. */
  85. } MCVertexStruct;
  86.  
  87. typedef struct MCEdgeStruct {
  88.     struct MCEdgeStruct *Pnext;                    /* To next in chain. */
  89.     CagdPType V[2];
  90.     CagdPType N[2];
  91. } MCEdgeStruct;
  92.  
  93. typedef struct MCPolygonStruct {
  94.     struct MCPolygonStruct *Pnext;                /* To next in chain. */
  95.     int NumOfVertices;
  96.     CagdPType V[13];
  97.     CagdPType N[13];
  98. } MCPolygonStruct;
  99.  
  100. MCPolygonStruct *MCThresholdCube(MCCubeCornerScalarStruct *CCS,
  101.                  RealType Threshold);
  102.  
  103. #endif /*  MARCH_CUBE_H */
  104.